package com.hj.ct.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	public final static int VERSION = 1;

	public DBHelper(Context context) {
		super(context, "jian_kong.db", null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DBConstants.SQL_ALARM);
		db.execSQL(DBConstants.SQL_USER);
		db.execSQL(DBConstants.SQL_DEVICE);
		db.execSQL(DBConstants.SQL_GATHER);
	}

	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

	public void clearTable(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS " + DBConstants.SQL_USER_TABLE);
		db.execSQL("DROP TABLE IF EXISTS " + DBConstants.SQL_ALARM_TABLE);
		db.execSQL("DROP TABLE IF EXISTS " + DBConstants.SQL_DEVICE);
		db.execSQL("DROP TABLE IF EXISTS " + DBConstants.SQL_GATHER);
		onCreate(db);
	}
}
